/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.incad.psh.pshassign.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 *
 * @author alberto
 */
public class Institution extends Composite {
    
    private static InstitutionUiBinder uiBinder = GWT.create(InstitutionUiBinder.class);
    
    @UiField
    FocusPanel box;
    @UiField
    Label label;
    @UiField
    Image remove;
    
    interface InstitutionUiBinder extends UiBinder<Widget, Institution> {
    }
    
    public Institution(String label) {
        initWidget(uiBinder.createAndBindUi(this));
        this.label.setText(label);
        box.addMouseOverHandler(new MouseOverHandler() {

            @Override
            public void onMouseOver(MouseOverEvent event) {
                remove.setVisible(true);
            }
        });
        
        box.addMouseOutHandler(new MouseOutHandler() {

            @Override
            public void onMouseOut(MouseOutEvent event) {
                remove.setVisible(false);
            }
        });
        
        remove.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
        remove.setVisible(false);
    }
}
